<?php
class Admin_Forms_ProductDownloadForm extends Zend_Form {
	function __construct($option = null) {
		$this->setAction('')
				->setMethod('POST')
				->setAttrib('enctype', 'multipart/form-data')
				->setAttrib('class', 'form-horizontal');
		$name = $this->createElement('text', 'name');
		$name->setRequired ( true )
		            ->addFilter('StringTrim')
		            ->setAttrib('class', 'form-control')
		            ->setLabel('Tên');
		$file = new Zend_Form_Element_File('file_download');
		$file->setLabel('Upload')
				->setDestination(PUBLIC_PATH . '/images/product_data/files')
				->addValidator('Size', false, '100MB')
				->setIgnore(true);
		$link = $this->createElement('text', 'link');
		$link->setRequired ( true )
		            ->addFilter('StringTrim')
		            ->setAttrib('class', 'form-control')
		            ->setLabel('Link download');
		$description = $this->createElement ( 'textarea', 'description' );
		$description->setRequired ( true )
				->setLabel('Nội dung')
				->setAttrib('rows', '3')
				->setAttrib('class', 'input-xlarge');
		$submit = $this->createElement('submit','submit',array ('label' => $option['submit'] ));
		$submit->setAttrib('class', 'btn btn-default');
		$cancel = $this->createElement('button', 'cancel',array('label'	=> 'Hủy bỏ','class'=>'btn btn-default','onclick'	=> 'windown:location = "' . $option['cancel_link'] . '"'));
		$this->addElement($name)
				->addElement($file)
				->addElement($link)
				->addElement($description)
				->addElement($submit)
				->addElement($cancel);
		$this->setDecorators(array('FormElements',array('HtmlTag',array('tag'	=> 'div','width'=>'100%')),'form'));
		$this->setElementDecorators(array(
										'ViewHelper',
										'Errors',
										'Description',
										array(	
											array('data'	=> 'HtmlTag'),
											array('tag'		=> 'div','class'	=> 'col-md-6')),
										array('label',
											array('class'	=> 'col-md-2 control-label','requiredSuffix'=>'(*)')),
										array(
											array('row'	=> 'HtmlTag',),
											array('class'=>'form-group')
		        						)
									)
								);
		$submit->setDecorators(array(
								'ViewHelper',
						       ));
		$cancel->setDecorators(array(
								'ViewHelper',
									)
						       );
		$file->setDecorators(array(
			'File',
			'Description',
			'Errors',
			array(array('data'=>'HtmlTag'), array('tag' => 'div',"class"	=> "col-md-6")),
			array('label',array('class'	=> 'col-md-2 control-label','requiredSuffix'=>'(*)')),
			array(
				array('row'	=> 'HtmlTag',),
				array('class'=>'form-group ','tag'	=> 'div')
			),
		));
//		$download_link->setDecorators(array(
//			'File',
//			'Description',
//			'Errors',
//			array(array('data'=>'HtmlTag'), array('tag' => 'div',"class"	=> "'requiredSuffix'=>'(*)'")),
//			array('label',array('class'	=> 'col-md-2 control-label','requiredSuffix'=>'(*)')),
//			array(
//				array('row'	=> 'HtmlTag',),
//				array('class'=>'form-group ','tag'	=> 'div')
//			),
//		));
//		$download_link_value->setDecorators(array('ViewHelper'));
		
		$this->addDisplayGroup(array('name',"file_download",'link',"description"),'input');
		$this->addDisplayGroup(array('submit','cancel'),'action');
		$input = $this->getDisplayGroup('input');
		$input->setDecorators(array(
                'FormElements',
                'Fieldset',
        ));
		$action = $this->getDisplayGroup('action');
		$action->setDecorators(array(
                'FormElements',
                'Fieldset',
                array('HtmlTag',array('tag'=>'div','class'	=> 'col-md-offset-2'))
        ));
	}
}